package com.eet.redis.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Redis自动配置
 * Configuration: 申明这是一个配置类
 * ConditionalOnWebApplication: 引用启动器的项目是web应用此自动配置模块才生效
 * EnableConfigurationProperties: 加载配置对象到容器
 * @author zheng.zhang
 */

@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties(RedisProperties.class)
public class RedisAutoConfiguration {

    @Autowired
    private RedisProperties redisProperties;

    @Bean
    public RedisService redisService() {
        RedisService redisService = new RedisService();
        redisService.setRedisProperties(redisProperties);
        return redisService;
    }
}
